{{ extend '../pub/template.html'}}

{{ block 'user-name' }}
当前登录用户{{msg}}&nbsp;&nbsp;用户角色：{{role == 'on' ? '管理员':'普通人'}}
{{ /block }}

{{ block 'user-position'}}

<!-- 面包屑导航 -->
<nav aria-label="breadcrumb">
  <ol class="breadcrumb">
    <li class="breadcrumb-item"><a href="/admin/user">首页</a></li>
    <li class="breadcrumb-item"><a>友情链接管理</a></li>
    <li class="breadcrumb-item active" aria-current="page">链接列表</li>
  </ol>
</nav>


<!-- 弹出框 -->
<div class="modal fade" id="staticBackdrop" data-backdrop="static" data-keyboard="false" tabindex="-1"
  aria-labelledby="staticBackdropLabel" aria-hidden="true">
  <form class="modal-dialog" action="/admin/dellinks" method="POST">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="staticBackdropLabel">确认删除</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        你确定要删除该文章吗？
        <input type="hidden" name="id" id="deleteLinksId">
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
        <button type="submit" class="btn btn-primary">确定</button>
      </div>
    </div>
  </form>
</div>


<div class="card border-0" style="margin: 16px;padding: 16px;min-height: 400px;">


  <!-- 添加公告按钮 -->
  <div class="card-header" style="background-color: #ffffff;border: 0px;padding-bottom: 0px;">
    <button type="button" class="btn btn-primary btn-sm" onclick="location.href='/admin/linksadd'">添加链接</button>
  </div>

  <div class="card-body" style="background-color: #ffffff;">
    <!-- 表格内容 -->
    <table class="table table-bordered table-striped" style="font-size: 13px;color: #909399;">
      <thead>
        <tr>
          <th scope="col" class="text-center">序号</th>
          <th scope="col" class="text-center">地址</th>
          <th scope="col" class="text-center">网址名称</th>
          <th scope="col" class="text-center">提示</th>
          <th scope="col" class="text-center">操作</th>
        </tr>
      </thead>
      <tbody>

        {{each resulf}}
        <tr>
          <th scope="row" class="text-center">{{$index+1}}</th>
          <td class="text-center">{{$value.url}}</td>
          <td class="text-center">{{$value.name}}</td>
          <td class="text-center">{{$value.alt}}</td>
          <td class="text-center">
            <button type="button" class="btn btn-primary btn-sm edit" style="font-size: 13px;"
              data-id="{{$value.id}}">编辑</button>
            <button type="button" class="btn btn-danger btn-sm del" style="font-size: 13px;" data-toggle="modal"
              data-target="#staticBackdrop" data-id="{{$value.id}}">删除</button>
          </td>
        </tr>
        {{/each}}
      </tbody>
    </table>

    <!-- 分页条 -->
    <!-- <nav aria-label="Page navigation example">
        <ul class="pagination pagination-sm  justify-content-center">
          <li class="page-item"><a class="page-link" href=""></a>
            <% for(var i=0; i < page; i++){ %>
          <li class="page-item"><a class="page-link" href="/admin/notice?id=<%= i+1 %>">
              <%= i+1 %>
            </a></li>
          <% } %>
        </ul>
      </nav> -->

  </div>
</div>
{{ /block}}

{{block 'script'}}
<script>
  $('.del').on('click', function () {
    console.log('点击了删除')
    $('#deleteLinksId').val($(this).attr('data-id'))

  })

</script>

{{/block}}